﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using Digitalmes.Model.QcManagement;
using Digitalmes.Model;



namespace Digitalmes.ViewModel.QcManagement.QcInspectRecordVMs
{
    public partial class QcInspectRecordSheetDetailListVM1 : BasePagedListVM<QcInspectRecord, QcInspectRecordDetailSearcher1>
    {
        
        protected override List<GridAction> InitGridAction()
        {
            return new List<GridAction>
            {
                this.MakeStandardAction("QcInspectRecord", GridActionStandardTypesEnum.AddRow, "新建","", dialogWidth: 800),
                this.MakeStandardAction("QcInspectRecord", GridActionStandardTypesEnum.RemoveRow, "删除","", dialogWidth: 800),
            };
        }
 
        protected override IEnumerable<IGridColumn<QcInspectRecord>> InitGridHeader()
        {
            return new List<GridColumn<QcInspectRecord>>{
                
                this.MakeGridHeader(x => x.QcType).SetEditType(EditTypeEnum.ComboBox,typeof(EquipTypeEnum).ToListItems(null,true)).SetTitle(@Localizer["Page.检验分类"].Value),
                this.MakeGridHeader(x => x.InspectName).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.检验项目"].Value),
                this.MakeGridHeader(x => x.InspectTool).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.检测工具"].Value),
                this.MakeGridHeader(x => x.Content).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.检验内容"].Value),
                this.MakeGridHeader(x => x.RefValue).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.参考值"].Value),
                this.MakeGridHeader(x => x.QcValue).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.检验值"].Value),
                this.MakeGridHeader(x => x.QcResult).SetEditType(EditTypeEnum.ComboBox,typeof(QcStatusEnum).ToListItems(null,true)).SetTitle(@Localizer["Page.检验结果"].Value),
                this.MakeGridHeader(x => x.Remark).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["_Admin.Remark"].Value),
                this.MakeGridHeader(x => x.OpCode).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.责任工位"].Value),

                this.MakeGridHeaderAction(width: 200)
            };
        }

        
        public override IOrderedQueryable<QcInspectRecord> GetSearchQuery()
        {
                
            var id = (long?)Searcher.SheetId.ConvertValue(typeof(long?));
            if (id == null)
                return new List<QcInspectRecord>().AsQueryable().OrderBy(x => x.ID);
            var query = DC.Set<QcInspectRecord>()
                .Where(x => id == x.SheetId)

                .OrderBy(x => x.ID);
            return query;
        }

    }

    public partial class QcInspectRecordDetailSearcher1 : BaseSearcher
    {
        
        [Display(Name = "_Model._QcInspectRecord._Sheet")]
        public string SheetId { get; set; }
    }

}

